package me.youline.dataServer.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "yline_base_userinfo")
public class UserBaseInfo implements Serializable{

	private static final long serialVersionUID = 8524700597574988612L;

	/**
	 * 性别
	 */
	public static enum Gender {
		MALE,//男性 
		FEMALE//女性
	}

	/**
	 * 用户来源
	 */
	public static enum From {
		APP_REGISTER , //直接通过手机注册
		THIRD_PART  //通过第三方注册
	}
	/**
	 * 用户ID
	 */
	@Id
	@GeneratedValue
	@Column
	private Long userId;
	
	/**
	 * 头像url
	 */
	@Column
	private String avatarUrl;
	
	/**
	 * 昵称
	 */
	@Column
	private String nickName;
	
	/**
	 * 邮箱号
	 */
	@Column
	private String mail;
	
	/**
	 * 性别
	 */
	@Column
	@Enumerated(EnumType.ORDINAL)
	private Gender gender;
	
	@Column
	private Date birthday;
	
	/**
	 * 手机号
	 */
	@Column
	private String phoneNum;
	
	/**
	 * 账户创建时间
	 */
	@Column
	@Temporal(TemporalType.TIMESTAMP)
	private Date createTime;
	
	/**
	 * 账户来源
	 */
	@Column
	@Enumerated(EnumType.ORDINAL)
	private From createdFrom;

	

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public String getAvatarUrl() {
		return avatarUrl;
	}

	public void setAvatarUrl(String avatarUrl) {
		this.avatarUrl = avatarUrl;
	}

	public String getNickName() {
		return nickName;
	}

	public void setNickName(String nickName) {
		this.nickName = nickName;
	}

	public String getMail() {
		return mail;
	}

	public void setMail(String mail) {
		this.mail = mail;
	}

	public Gender getGender() {
		return gender;
	}

	public void setGender(Gender gender) {
		this.gender = gender;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public From getCreatedFrom() {
		return createdFrom;
	}

	public void setCreatedFrom(From createdFrom) {
		this.createdFrom = createdFrom;
	}

	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public String getPhoneNum() {
		return phoneNum;
	}

	public void setPhoneNum(String phoneNum) {
		this.phoneNum = phoneNum;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((avatarUrl == null) ? 0 : avatarUrl.hashCode());
		result = prime * result
				+ ((birthday == null) ? 0 : birthday.hashCode());
		result = prime * result
				+ ((createTime == null) ? 0 : createTime.hashCode());
		result = prime * result
				+ ((createdFrom == null) ? 0 : createdFrom.hashCode());
		result = prime * result + ((gender == null) ? 0 : gender.hashCode());
		result = prime * result + ((mail == null) ? 0 : mail.hashCode());
		result = prime * result
				+ ((nickName == null) ? 0 : nickName.hashCode());
		result = prime * result
				+ ((phoneNum == null) ? 0 : phoneNum.hashCode());
		result = prime * result + ((userId == null) ? 0 : userId.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		UserBaseInfo other = (UserBaseInfo) obj;
		if (avatarUrl == null) {
			if (other.avatarUrl != null)
				return false;
		} else if (!avatarUrl.equals(other.avatarUrl))
			return false;
		if (birthday == null) {
			if (other.birthday != null)
				return false;
		} else if (!birthday.equals(other.birthday))
			return false;
		if (createTime == null) {
			if (other.createTime != null)
				return false;
		} else if (!createTime.equals(other.createTime))
			return false;
		if (createdFrom != other.createdFrom)
			return false;
		if (gender != other.gender)
			return false;
		if (mail == null) {
			if (other.mail != null)
				return false;
		} else if (!mail.equals(other.mail))
			return false;
		if (nickName == null) {
			if (other.nickName != null)
				return false;
		} else if (!nickName.equals(other.nickName))
			return false;
		if (phoneNum == null) {
			if (other.phoneNum != null)
				return false;
		} else if (!phoneNum.equals(other.phoneNum))
			return false;
		if (userId == null) {
			if (other.userId != null)
				return false;
		} else if (!userId.equals(other.userId))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "UserBaseInfo [userId=" + userId + ", avatarUrl=" + avatarUrl
				+ ", nickName=" + nickName + ", mail=" + mail + ", gender="
				+ gender + ", birthday=" + birthday + ", phoneNum=" + phoneNum
				+ ", createTime=" + createTime + ", createdFrom=" + createdFrom
				+ "]";
	}

	

}
